package hz.mobileproject.pda.toolsmanager.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.toolsmanager.bean.response.RP_BorrowedTool;
import hz.mobileproject.pda.ui.base.BaseCustomAdapter;

/**
 * Created by Lc on 2018/5/4.
 */

public class ToolsRecyclerAlreadyLVAdaper extends BaseCustomAdapter<RP_BorrowedTool,ToolsRecyclerAlreadyLVAdaper.ViewHolder> {

    private OnDeleteClickListener onDeleteClickListener;

    public ToolsRecyclerAlreadyLVAdaper(Context mContext, List<RP_BorrowedTool> list) {
        super(mContext, list);
    }

    @Override
    protected int bindView() {
        return R.layout.item_tools_grant_lv;
    }

    @Override
    protected ViewHolder createViewHolder() {
        return new ViewHolder();
    }

    @Override
    protected void bindData(int position, View convertView, ViewHolder viewHolder) {
        viewHolder.mPosition = position;
        viewHolder.tv_toolType.setText(mList.get(position).getTool_type_name());
        viewHolder.tv_toolName.setText(mList.get(position).getTool_name());
    }

    class ViewHolder{
        @ViewInject(R.id.tv_toolType)
        private TextView tv_toolType;
        @ViewInject(R.id.tv_toolName)
        private TextView tv_toolName;

        private int mPosition;

        @Event({R.id.tv_delete})
        private void onViewClick(View v){
            switch (v.getId()){
                case R.id.tv_delete:
                    if(onDeleteClickListener != null){
                        onDeleteClickListener.onAlreadyLvDeleteClick(mPosition);
                    }
                    break;
            }
        }
    }



    public ToolsRecyclerAlreadyLVAdaper setOnDeleteClickListener(OnDeleteClickListener onDeleteClickListener) {
        this.onDeleteClickListener = onDeleteClickListener;
        return this;
    }

    public interface OnDeleteClickListener{
        void onAlreadyLvDeleteClick(int position);
    }
}
